/*
 * File : examRecord.js
 * Version : 0.1
 * Description : 针对体格检查所做的一系列js处理
 * Author : hxin
 * Created :2011/8/4
 * 
 */
$(document).ready(function(){
	$.getJSON("physical!checkJsonData.action",function(json){
		common(json);	
	});
});

//输出返回的json数据
function common(json){
	$("#checkId").html("");
	$.each(json,function(i){
		$("#checkId").append(
		"<tr>"+
		"<td>"+json[i].bodyWeight+"</td>"+
		"<td>"+json[i].bodyWeightIndex+"</td>"+ 
		"<td>"+json[i].systolicPressure+"</td>"+
		"<td>"+json[i].diastolicPressure+"</td>"+
		"<td>"+json[i].examDate+"</td>"+
		"<td>"+"<a href='#' onclick='deletePhysical("+json[i].id+")'>"+"删除"+"</a>"+"</td>"+
		"</tr>"
		);	
	});
}
//删除体格检查记录
function deletePhysical(id) {
	$.getJSON("physical!delete.action",{id:id},function(json){
		common(json);
	});
}
//保存体检检查记录
function save(){
	var form = document.getElementById("phyInputForm");
	form.action = "physical!save.action";
	form.submit();
	parent.location.href="clinic-record-input.action";
	
}
//在下拉列表框中选择不同值弹出对应的dialog
function selec(){
	if ("28" == $("#parentId").val()) {
			$("#physicalResult").show();
			$("#examResult").hide();
			var url = "physical-input.action";
			$("<iframe id='editFrame' width='200px' height='200px'/>").attr("src",
					url).dialog({
				autoOpen : true,
				modal : false,
				title : "添加体格项目",
				width : 200,
				height : 200,
				close : true
			});

		} else {
			$("#examResult").show();
			$("#physicalResult").hide();
			var url = "exam-record.action?checkItem="
					+ $("#parentId").find('option:selected').text();
			$("<iframe id='editFrame' width='200px' height='200px'/>").attr("src",
					url).dialog({
				autoOpen : true,
				modal : false,
				title : "添加常规检查项目",
				height : 200,
				close: function() {
					$.getJSON("exam-record!checkExamRecord.action",{id:0},function(json){
						//输出返回的json数据
						$("#examRecord").html("");
						$.each(json,function(i){
							$("#examRecord").append(
							"<tr>"+
							"<td>"+json[i].item.term+"</td>"+
							"<td>"+json[i].qualitation+"</td>"+ 
							"<td>"+json[i].examResult+"</td>"+
							"<td>"+json[i].unit+"</td>"+
							"<td>"+json[i].explanation+"</td>"+
							"<td>"+json[i].referenceStandard+"</td>"+
							"<td>"+"<a href='#' onclick='deleteExamRecord("+json[i].id+")'>"+"删除"+"</a>"+"</td>"+
							"</tr>"
							);	
						});
					});
				}
			});
		}
	}